package com.ruoyi.beforehand.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.beforehand.domain.InfoBulkAddDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.beforehand.domain.InfoBeforehandEvaluateDetail;
import com.ruoyi.beforehand.service.IInfoBeforehandEvaluateDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 事前评估详情Controller
 *
 * @author ruoyi
 * @date 2022-02-24
 */
@RestController
@RequestMapping("/beforehand/detail")
@Api(tags = "事前评估详情")
public class InfoBeforehandEvaluateDetailController extends BaseController
{
    @Autowired
    private IInfoBeforehandEvaluateDetailService infoBeforehandEvaluateDetailService;

    /**
     * 查询事前评估详情列表
     */
    @PreAuthorize("@ss.hasPermi('beforehand:detail:list')")
    @GetMapping("/list")
    @ApiOperation("查询事前评估详情列表")
    @ApiImplicitParam(name = "infoBeforehandEvaluateDetail", value = "实体类", dataType = "InfoBeforehandEvaluateDetail")
    public TableDataInfo list(InfoBeforehandEvaluateDetail infoBeforehandEvaluateDetail)
    {
        startPage();
        List<InfoBeforehandEvaluateDetail> list = infoBeforehandEvaluateDetailService.selectInfoBeforehandEvaluateDetailList(infoBeforehandEvaluateDetail);
        return getDataTable(list);
    }

    /**
     * 导出事前评估详情列表
     */
    @PreAuthorize("@ss.hasPermi('beforehand:detail:export')")
    @Log(title = "事前评估详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoBeforehandEvaluateDetail infoBeforehandEvaluateDetail)
    {
        List<InfoBeforehandEvaluateDetail> list = infoBeforehandEvaluateDetailService.selectInfoBeforehandEvaluateDetailList(infoBeforehandEvaluateDetail);
        ExcelUtil<InfoBeforehandEvaluateDetail> util = new ExcelUtil<InfoBeforehandEvaluateDetail>(InfoBeforehandEvaluateDetail.class);
        util.exportExcel(response, list, "事前评估详情数据");
    }

    /**
     * 获取事前评估详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('beforehand:detail:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取事前评估详情详细信息")
    @ApiImplicitParam(name = "id", value = "id", dataType = "Long")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(infoBeforehandEvaluateDetailService.selectInfoBeforehandEvaluateDetailById(id));
    }

    /**
     * 新增事前评估详情
     */
    @PreAuthorize("@ss.hasPermi('beforehand:detail:add')")
    @Log(title = "事前评估详情", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增事前评估详情")
    @ApiImplicitParam(name = "infoBeforehandEvaluateDetail", value = "实体类", dataType = "InfoBeforehandEvaluateDetail")
    public AjaxResult add(@RequestBody InfoBeforehandEvaluateDetail infoBeforehandEvaluateDetail)
    {
        return toAjax(infoBeforehandEvaluateDetailService.insertInfoBeforehandEvaluateDetail(infoBeforehandEvaluateDetail));
    }

    /**
     * 修改事前评估详情
     */
    @PreAuthorize("@ss.hasPermi('beforehand:detail:edit')")
    @Log(title = "事前评估详情", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改事前评估详情")
    @ApiImplicitParam(name = "infoBeforehandEvaluateDetail", value = "实体类", dataType = "InfoBeforehandEvaluateDetail")
    public AjaxResult edit(@RequestBody InfoBeforehandEvaluateDetail infoBeforehandEvaluateDetail)
    {
        return toAjax(infoBeforehandEvaluateDetailService.updateInfoBeforehandEvaluateDetail(infoBeforehandEvaluateDetail));
    }

    /**
     * 删除事前评估详情
     */
    @PreAuthorize("@ss.hasPermi('beforehand:detail:remove')")
    @Log(title = "事前评估详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除事前评估详情")
    @ApiImplicitParam(name = "ids", value = "id", dataType = "Long[]")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoBeforehandEvaluateDetailService.deleteInfoBeforehandEvaluateDetailByIds(ids));
    }

    /**
     * 批量新增
     */
    @RequestMapping(value = "/bulkadd", method = RequestMethod.POST)
    @ApiOperation("批量新增")
    @ApiImplicitParam(name = "infoBulkAddVo",value = "实体类", dataType = "InfoBulkAddVo")
    public AjaxResult bulkAdd(@RequestBody InfoBulkAddDetailVo infoBulkAddDetailVo){
        return toAjax(infoBeforehandEvaluateDetailService.insertInfoBeforehandEvaluateDetailList(infoBulkAddDetailVo));
    }
}
